package rpc.retry;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

import java.net.InetSocketAddress;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.ThreadPoolExecutor;

public class RetryPluginImpl implements RetryPlugin{

    @Autowired
    DelayQueue<RetryTask> retryTaskDelayQueue;
    @Autowired
    ThreadPoolExecutor threadPoolExecutor;

    @Override
    @Scheduled
    public void retry() throws InterruptedException {
        while (true){
            threadPoolExecutor.submit(retryTaskDelayQueue.take());
        }
    }

    @Override
    public void cause(InetSocketAddress address, Throwable throwable) {

    }
}
